home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2614.ZIP / TBROWS.ZIP / TTBR1.PRG next >
Text File  |  1990-10-22  |  2KB  |  93 lines

  1. /*****
  2.  *
  3.  * TTBR1.PRG
  4.  * First example for TBROWSE class using a database file
  5.  *
  6.  * 18 October 90
  7.  * Luiz Quintela - Nantucket Corp
  8.  *
  9.  * Clipper ttbr1 /N/W/A/B
  10.  * RTLINK FILE ttbr1 PLL base50
  11.  *
  12.  */
  13.  
  14. // Include Header Files
  15. // This will make handling keystrokes 
  16. // a bit easier!
  17. #include "inkey.ch"
  18.  
  19. FUNCTION Main()
  20. // Your variables
  21. LOCAL b, column, nKey
  22. SET SCOREBOARD OFF
  23. SET DATE       BRITISH
  24. SET CONFIRM    ON
  25.  
  26. // First open your file, with indexes, etc.
  27. USE test INDEX test NEW            // Use NEW in lieu of SELECT 0
  28.  
  29. // Prepare a beautiful color screen
  30. // I do not like to put several commands in a single line
  31. // but this is just to show what you can do with Clipper
  32. SETCOLOR( "BG/B,GR+/B,,,BG/N" ); CLS
  33.  
  34. // Ok! Now is time to create a TBrowseDB object
  35. // TBrowseDB( top, left, bottom, right ) ===> Object
  36.  
  37. b := TBrowseDB( 2, 2, 20, 78)
  38.  
  39. // Note that TBrowseDB() creates an object with no column
  40. // objects. In order to make the object usable, a column must be
  41. // added for each field to display.
  42. // In this example we will use three fields.
  43. // TBColumnNew( cHeading, bBlock ) =====> Object
  44.  
  45. column := TBColumnNew( "Field 1", {|| test->fld1} )
  46.  
  47. // Returns a new column object with specified heading and data
  48. // retrieval block
  49.  
  50. b:addColumn( column )
  51.  
  52. // addColumn( objColumn ) =====> self
  53. // Adds a new column object to the browse object and 
  54. // TBrowse:colCount is increased by one.
  55. // Repeat the same to other fields
  56.  
  57. column := TBColumnNew( "Field 2", {|| test->fld2} )
  58. b:addColumn( column )
  59. column := TBColumnNew( "Field 3", {|| test->fld3} )
  60. b:addColumn( column )
  61.  
  62. // It is time to put this programme to work
  63. WHILE .T.
  64.    // Ok! It is time to stabilize display
  65.    // stabilize() =====> self
  66.    // Performs incremental stabilization. Stabilization is 
  67.     // performed in increments so that it can be interrupted 
  68.     // by any asynchronous event.
  69.    // A value of .T. is returned indicating the object is stable
  70.  
  71.    WHILE ( !b:stabilize() )
  72.       nKey := InKey()
  73.       IF ( nKey != 0 )
  74.          EXIT // abort if a key is waiting
  75.  
  76.       ENDIF
  77.  
  78.    END
  79.  
  80.    // b:stable contains .T. if the browse object is stable
  81.  
  82.    // Display is stable
  83.    IF ( b:stable )  // everything's done; just wait for a key
  84.       nKey := INKEY(0)
  85.  
  86.    ENDIF
  87.  
  88.    QUIT
  89.  
  90. END
  91.  
  92. /* EOF - TTBR1.PRG */
  93.